<template>
    <div class="cont">
        <CustomForm @submit="submit" title="新增优惠卷" :formList="formList"></CustomForm>
    </div>
</template>

<script setup lang="ts">
import CustomForm from '@/components/customForm/CustomForm.vue';
import { CustomFormItem, CustomFormState } from '@/components/customForm/types';

const formList = reactive<CustomFormItem[]>([
    {label:'优惠卷名称',key:'name',type: 'input',required:true},
    {label: '',key:'money',type:'discount'},
    {label:'优惠卷类型',key:'type',type: 'select',required:true,options:[
        {label:'全部',value:'1'},
        {label:'帮我送',value:'2'},
        {label:'帮我取',value:'3'},
        {label:'帮我买',value:'4'},
    ]},
    {label:'有效天数',key:'effectiveDays',type: 'input',tip:'领取后开始计算到期时间, -1为不限'},
    {label:'限制领取数量',key:'limitQuantity',type: 'input'},
    {label:'状态',key:'state',type: 'radio',options:[
        {label:'启用',value:'1'},
        {label:'禁用',value:'2'},
    ]},
    { value: '提交并保存', key: 'submit', type: 'submit' },
])

const submit = (formState: CustomFormState) => {
    alert('表单结果为' + JSON.stringify(formState))
}
</script>

<style scoped></style>